﻿using System.Collections.Generic;
using Microsoft.Data.Schema.ScriptDom.Sql;
//using System.Diagnostics;
using System;
using System.IO;
using System.Text.RegularExpressions;




namespace Neznayka
{
    internal class EnforceNamedConstraintVisitor : TSqlConcreteFragmentVisitor
    {
        private List<Constraint> _constraints;

        #region ctor
        public EnforceNamedConstraintVisitor()
        {
            _constraints = new List<Constraint>();
        }
        #endregion

        #region properties
        public List<Constraint> Constraints
        {
            get { return _constraints; }
        }
        #endregion

        #region overrides
        public override void ExplicitVisit(CheckConstraint node)
        {
            if (node.ConstraintIdentifier == null || String.IsNullOrEmpty(node.ConstraintIdentifier.Value))
            {
                _constraints.Add(node);
            }
        }
        public override void ExplicitVisit(UniqueConstraint node)
        {
            if (node.ConstraintIdentifier == null || String.IsNullOrEmpty(node.ConstraintIdentifier.Value))
            {
                _constraints.Add(node);
            }
        }
        public override void ExplicitVisit(DefaultConstraint node)
        {
            if (node.ConstraintIdentifier == null || String.IsNullOrEmpty(node.ConstraintIdentifier.Value))
            {
                _constraints.Add(node);
            }
        }
        public override void ExplicitVisit(ForeignKeyConstraint node)
        {
            if (node.ConstraintIdentifier == null || String.IsNullOrEmpty(node.ConstraintIdentifier.Value))
            {
                _constraints.Add(node);
            }
        }
        //public override void ExplicitVisit(NullableConstraint node)
        //{
        //    _constraints.Add(node);
        //}

        #endregion

    }


}